/*
 * @Description  :
 * @Autor        : guoxi
 * @Date         : 2022-06-06 15:10:29
 * @LastEditors  : Please set LastEditors
 * @LastEditTime : 2022-06-06 15:17:51
 * @FilePath     : \rpms\src\main.ts
 */
import { createApp, Directive } from "vue";
import App from "./App.vue";
import { useElementPlus } from "../src/plugins/element-plus";

// import "./style/element-theme.scss";
import { usI18n } from "../src/plugins/i18n";
import router from "./router";
import { setupStore } from "/@/store";
// import { getServerConfig } from "./config";

// notification 样式单独引入
import "element-plus/theme-chalk/el-notification.css";

// 导航进度条样式
import "nprogress/nprogress.css";
// 导入公共样式
import "./style/index.scss";
// 导入字体图标
import "./assets/iconfont/iconfont.js";
import "./assets/iconfont/iconfont.css";

const app = createApp(App);

// 响应式storage
import Storage from "responsive-storage";

app.use(Storage, {
  routesInStorage: {
    type: Array,
    default: Storage.getData(undefined, "routesInStorage") ?? [
      {
        path: "/welcome",
        parentPath: "/",
        meta: {
          title: "message.hshome",
          icon: "el-icon-s-home",
          showLink: true,
          savedPosition: false
        }
      }
    ]
  },
  // 国际化 默认中文zh
  locale: {
    type: Object,
    default: Storage.getData(undefined, "locale") ?? {
      locale: "zh"
    }
  },
  // layout模式以及主题
  layout: {
    type: Object,
    default: Storage.getData(undefined, "layout") ?? {
      layout: "vertical-dark"
    }
  },
  memory: {
    starValue: Storage.getData("starValue", "rdms-") ?? 1
  }
});

// 自定义指令
import * as directives from "/@/directives";

import rePagination from "/@/components/RePagination";

Object.keys(directives).forEach(key => {
  app.directive(key, (directives as { [key: string]: Directive })[key]);
});

// getServerConfig(app).then(async () => {
setupStore(app);
// element-plus 全局配置
app.config.globalProperties.$ELEMENT = { size: "small" };
if (import.meta.env.VITE_PROJECT_ENV === "pre") {
  window["ecmDocType"] = {
    common:
      "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/03E932D18D3545D689C191C75C1EAA8E",
    patent:
      "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/757F6F3DA2264943A71450280EB52E30/CA25EC0B509D46F78D8362CD0E78485C",
    software:
      "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/757F6F3DA2264943A71450280EB52E30/478EA7AA1AE64C609CA10B2EDA0C3022",
    paper:
      "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/757F6F3DA2264943A71450280EB52E30/7E9E13A50E05434C92E382D336E6AAFB",
    book: "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/757F6F3DA2264943A71450280EB52E30/D5C2B46EB66F48C1B3B8BAEC80CDF352",
    standard:
      "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/757F6F3DA2264943A71450280EB52E30/2ED2731E71774876AD9272ECD938E867",
    award:
      "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/757F6F3DA2264943A71450280EB52E30/F437325B9FE3491A8653CBDABB4C5B39",
    docOther:
      "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/757F6F3DA2264943A71450280EB52E30/47EB1A7CB395497890583A2C1612FC80",
    communication:
      "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/7D48FC9915394E67A66B8D7506B70740",
    information:
      "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/8319F78F3EF944CB8AE18984126D5730",
    contract:
      "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/6AAE9211A5814A398E9AAAE8E2BD104D",
    project:
      "gns://CC51446EBA604338BB94197FEC0615D3/4565F3152A0642BBB253154BE9426C2D/28EC072AA3DB47E78A6C545525281162"
  };
} else {
  window["ecmDocType"] = {
    common:
      "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/6C680974760640028E898118FCB351E4",
    patent:
      "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/8EF43A987AF5480F92EEC36BF3A3CBDC/892261B52D69433581910DA18181E432",
    software:
      "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/8EF43A987AF5480F92EEC36BF3A3CBDC/68E46CE1520042CBA8DCEE91F08BE12B",
    paper:
      "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/8EF43A987AF5480F92EEC36BF3A3CBDC/1DDC8C0D7EF3439E8D09820620EA5698",
    book: "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/8EF43A987AF5480F92EEC36BF3A3CBDC/9A28EB0883CD4DCB8DDFB64BD1ACF005",
    standard:
      "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/8EF43A987AF5480F92EEC36BF3A3CBDC/FFC98CE07B9A4BBDA3336D755C8E45F5",
    award:
      "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/8EF43A987AF5480F92EEC36BF3A3CBDC/DAA3775B64314A4E8997054B1EEC0B1A",
    docOther:
      "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/8EF43A987AF5480F92EEC36BF3A3CBDC/10C85551FD7B4B1DA714A1F47FB87CFD",
    communication:
      "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/C33CB7DAEFA44643B35AE7F708D9BA2B",
    information:
      "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/D23609CE30D1485A9C19904E124A79D8",
    contract:
      "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/9B874EAFF79E4D76A4C48F0150864023",
    project:
      "gns://269DB7E528FB4664AA3B63FF8D83BC3C/BA8FEB58DD3A46A8B05804D8210132C3/22B22B6A76F748E3B61F320130D32D15"
  };
}

app.use(useElementPlus).use(router).use(usI18n).use(rePagination);
router.isReady();

app.mount("#app");
// });
